package apk.yoursms.ad;

import android.os.Bundle;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.Toast;
import apk.yoursms.R;
import apk.yoursms.TitleBar;
import apk.yoursms.views.TextView;

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

public class ShowAd extends TitleBar {

    @Override
    public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.ad);

	Bundle child = getIntent().getExtras();
	TextView title = (TextView) findViewById(R.id.title);
	title.setText(child.getString("name_child"));

	LinearLayout LLAdmobClick = (LinearLayout) findViewById(R.id.adView);
	AdView mClickAdView = new AdView(ShowAd.this, AdSize.SMART_BANNER,
		getString(R.string.admob_publisher_id));
	mClickAdView.setAdListener(new AdListenerPopUp(this, LLAdmobClick,
		mClickAdView));
	mClickAdView.loadAd(new AdRequest());
	LLAdmobClick.addView(mClickAdView);

    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
	if (keyCode == KeyEvent.KEYCODE_BACK) {
	    Toast toast = Toast.makeText(this, getString(R.string.ad_need_visited), Toast.LENGTH_SHORT);
	    toast.setGravity(Gravity.CENTER, 0, 0);
	    toast.show();
	}
	return false;
    }

}
